#include <init_map.h>


inline std::ostream& operator<< (std::ostream& os, const cell_values_map& i)
{
   os << "va1 = " << i.val1 << ", val2 = " << i.val2 << ", val3 = " << i.val3;
   return os;
}

std::string file_get_string(std::istream& file)
{
   std::string res;
   std::getline(file, res);
   return res;
}


std::vector<std::string> split_to_substring(const std::string& str)
{
   std::string tmp;
   std::vector<std::string> res;
   std::istringstream is(str);
   while ( is >> tmp )
   {
      res.push_back(tmp);
   }
   return res;
}

cell_values_map substring_to_item(const std::string& str)
{
   cell_values_map res;
   std::string tmp(str);
   std::replace(tmp.begin(), tmp.end(), '.', ' ');
   std::istringstream is(tmp);
   is >> res.val1 >> res.val2 >> res.val3;
   return res;
}

std::vector<cell_values_map> substrings_to_items(const std::vector<std::string>& strings)
{
   std::vector<cell_values_map> res;
   std::vector<std::string>::const_iterator beg = strings.begin();
   std::vector<std::string>::const_iterator end = strings.end();
   for ( ; beg != end; ++beg )
   {
      res.push_back(substring_to_item(*beg));
   }
   return res;
}


